<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>播放视频 - {{ video_name }}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            min-height: 100vh;
        }
        .navbar {
            background: rgba(255, 255, 255, 0.9) !important;
            backdrop-filter: blur(10px);
            border-bottom: 1px solid #e0e0e0;
        }
        .video-container {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-bottom: 20px;
        }
        .video-player {
            width: 100%;
            border-radius: 8px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
        }
        .video-info {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 16px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-top: 20px;
        }
        .back-btn {
            background: #6c757d;
            color: white;
            border-radius: 8px;
            padding: 10px 20px;
            font-weight: 600;
            transition: all 0.3s ease;
        }
        .back-btn:hover {
            background: #5a6268;
            transform: translateY(-2px);
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light">
        <div class="container">
            <a class="navbar-brand d-flex align-items-center" href="/">
                <i class="fas fa-video me-2"></i>
                <span class="fw-bold">视频中心</span>
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link active" href="/">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">关于</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">联系</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 视频播放区域 -->
    <section class="py-5">
        <div class="container">
            <div class="video-container text-center">
                <h2>{{ video_name }}</h2>
                
                <!-- HTML5 Video Player with Controls -->
                <video id="videoPlayer" class="video-player" controls preload="metadata">
                    <source src="/videos/{{ video_name }}" type="video/mp4">
                    您的浏览器不支持视频播放。
                </video>
                
                <div class="mt-3">
                    <a href="/" class="btn back-btn">
                        <i class="fas fa-arrow-left me-2"></i>返回视频列表
                    </a>
                </div>
            </div>

            <!-- 视频信息 -->
            <div class="video-info">
                <h4>视频详情</h4>
                <p><strong>文件名:</strong> {{ video_name }}</p>
                <p><strong>时长:</strong> {{ get_video_duration(video_name) }}</p>
            </div>
        </div>
    </section>

    <!-- Bootstrap JS和依赖项 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <!-- 自定义JavaScript代码来处理视频播放器功能 -->
    <script>
        // 确保视频播放器的进度条可以正常拖动
        document.addEventListener('DOMContentLoaded', function() {
            const videoPlayer = document.getElementById('videoPlayer');
            
            // 添加事件监听器确保拖拽功能正常工作
            videoPlayer.addEventListener('loadedmetadata', function() {
                console.log("视频元数据已加载");
            });
            
            // 确保进度条可以拖动的处理函数
            videoPlayer.addEventListener('timeupdate', function() {
                // 这里可以添加额外的时间更新逻辑，如果需要的话
            });
            
            // 添加对拖拽进度条的支持
            videoPlayer.addEventListener('seeking', function() {
                console.log("正在拖拽进度条");
            });
            
            videoPlayer.addEventListener('seeked', function() {
                console.log("拖拽完成，当前时间:", videoPlayer.currentTime);
            });
            
            // 修复视频播放器的进度条拖动问题
            videoPlayer.addEventListener('loadstart', function() {
                console.log("开始加载视频");
            });
            
            // 确保在视频准备就绪后可以正常拖动
            videoPlayer.addEventListener('canplay', function() {
                console.log("视频已准备好播放");
            });
        });
    </script>
</body>
</html>